/* 
 *	Copyright 2014  Yanqing Wu
 *		email: yqwu_yqwu@126.com
 *
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
*/

#pragma once
#include "StdCtrlSkinCell.h"
#include "StdCtrlSkinBgCellAttrib.h"

#include <atlimage.h>

class CStdCtrlSkinBgCell : public CStdCtrlSkinCell
{
public:
	CStdCtrlSkinBgCellAttrib bgAttrib;
public:
	CStdCtrlSkinBgCell(void) : CStdCtrlSkinCell()
	{
	}
	CStdCtrlSkinBgCell(CComPtr<IXMLDOMNode> spNode, CStdCtrlSkinRow* pRow)
	{
		InitDataElt(pRow);
		LoadXmlNode(spNode);
	}
	virtual ~CStdCtrlSkinBgCell(void)
	{
	}

	virtual void Draw(HDC hDC);

#ifdef __DUMPTEST
	virtual void Dump(std::ofstream& fio, CStdCtrlSkin_EnumDump type) override;
#endif

protected:
	virtual bool LoadXmlNode(CComPtr<IXMLDOMNode> spNode) override;

	virtual void DrawGradient(HDC hDC, int width, int height);
	virtual void DrawImage(HDC hDC, CRect& rect, CImage* pImg);
	//	When drawing center mode, the rect has to be changed in case the
	//	image is smaller than cell, in order to avoid bg error
	virtual void DrawImageCenter(HDC hDC, CRect& rect, CImage* pImg);
	virtual void DrawImageTile(HDC hDC, CRect rect, CImage* pImg);
	virtual void DrawImageStretch(HDC hDC, CRect rect, CImage* pImg);

	virtual void DoAlphaBlend(HDC hDC, HDC hSrc, CRect rectSrc, CRect rectDst);
	virtual void DoTransparent(HDC hDC, HDC hSrc, CRect rectSrc, CRect rectDst);
	virtual void DoBmpCopy(HDC hDC, HDC hSrc, CRect rectSrc, CRect rectDst);
};

